package com.wink_172.library;


import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
import android.util.Log;

/**
 * 不需和Activity交互的本地服务
 * https://www.cnblogs.com/pepcod/archive/2013/02/11/2937403.html
 * */
public class LocalService extends Service {

    private static final String TAG = "LocalService";
    public class LocalBinder extends Binder {
        public LocalService getService() {
            return LocalService.this;
        }
    }

    @Override
    public void onCreate() {
        Log.e(TAG, "====>>onCreate");
        super.onCreate();
    }

    @Override
    public void onDestroy() {
        Log.e(TAG, "====>>onDestroy");
        super.onDestroy();
    }

    @Override
    public void onStart(Intent intent, int startId) {
        Log.e(TAG, "====>>onStart");
        super.onStart(intent, startId);
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        Log.e(TAG, "====>>Received start id " + startId + ": " + intent);
// We want this service to continue running until it is explicitly
// stopped, so return sticky.
        return START_STICKY;
    }

    @Override
    public IBinder onBind(Intent intent) {
        Log.e(TAG, "onBind: ====>>" );
        return mBinder;
    }

    // This is the object that receives interactions from clients. See
// RemoteService for a more complete example.
    private final IBinder mBinder = new LocalBinder();

}
